Maple 2025 Questions and Posts

These are Posts and Questions associated with the product, Maple 2025

I want the Minkowski metric in spherical coordinates, so I do the following:

restart;

with(Physics):

Setup(coordinatesystems=spherical,signature=`-+++`);

`Systems of spacetime coordinates are:`*{X = (t, r, theta, phi)}

 

[coordinatesystems = {X}, signature = `- + + +`]

(1)

g_[lineelement]

-Physics:-d_(t)^2+Physics:-d_(r)^2+Physics:-d_(theta)^2+Physics:-d_(phi)^2

(2)

 

Which is not correct, it should return:

-d_(t)^2 + d_(r)^2 + r^2*d_(theta)^2 + r^2*sin(theta)^2*d_(phi)^2

Any ideas why it is giving the wrong answer? I usually just define my metric manually, but I was curious why this is occuring. I also noticed something else strange: after running the worksheet, if I go back to the setup line and execute, it will return the correct expression! But if I execute restart and then Setup again, wrong answer. 

Any thoughts would be appreciated, thanks! 

What is the opinion here on the following. If given   A which is linear in x, but not simplified. now type(A,x) gives false.  But type(simplify(A),x) gives true.

Does this mean it is the user responsibility to simplify the expression first before calling type on it? 

Why does not type command do this internally to see if it is linear before deciding? What is the reason for this design choice?

interface(version);

`Standard Worksheet Interface, Maple 2025.2, Windows 10, November 11 2025 Build ID 1971053`

restart;

 

A:=(x+y+1)^2-(x+y-1)^2;

(x+y+1)^2-(x+y-1)^2

simplify(A);

4*x+4*y

type(A,linear(y))

false

type(simplify(A),linear(y))

true

type(A,linear(x))

false

type(simplify(A),linear(x))

true

 

 

Download why_simplify_is_needed_feb_9_2026.mw

I have created three random variables:  r, theta and phi.  That went as I expected.  I then did some math with these random variable.  I calculated the following:  sin(phi), sin(theta), cos(phi) and cos(theta).

When I viewed the PDFs of these above four, I get what I expected with the exception of sin(theta).  I got an error message telling me that I provided three arguments when Maple expected only two arguments.  I am confused as to why this happened.

I wonder if I broke any rules when I named these variables, but I don't know...any suggestions? My work is attached.

with(Statistics)

theta := RandomVariable(Uniform(0, 2*Pi))

_R

(1)

phi := arccos(-1+2*RandomVariable(Uniform(0, 1)))

arccos(-1+2*_R0)

(2)

r := RandomVariable(Uniform(0, 1))^(1/3)

_R1^(1/3)

(3)

SinPhi := sin(phi)

2*(-_R0^2+_R0)^(1/2)

(4)

PDF(SinPhi, t)

piecewise(t <= 0, 0, t < (1/2)*4^(1/2), t/(-t^2+1)^(1/2), (1/2)*4^(1/2) <= t, 0)

(5)

SinTheta := sin(theta)

sin(_R)

(6)

PDF(SinTheta, t)

Error, (in Statistics:-PDF) invalid input: type expects 2 arguments, but received 3

 

CosPhi := cos(phi)

-1+2*_R0

(7)

PDF(CosPhi, t)

(1/2)*piecewise((1/2)*t < -1/2, 0, (1/2)*t < 1/2, 1, 0)

(8)

CosTheta := cos(theta)

cos(_R)

(9)

PDF(CosTheta, t)

piecewise(t <= -1, 0, t < 1, 1/(Pi*(-t^2+1)^(1/2)), 1 <= t, 0)

(10)
 

NULL

Download Basics.mw

Could someone suggest a way to help dsolve be able to obtain this solution to this complicated first order ode? In V 2025.2 it is not able to solve it as is

interface(version);

`Standard Worksheet Interface, Maple 2025.2, Windows 10, November 11 2025 Build ID 1971053`

ode:=-x*sqrt((1 - x)/(x + 1))*(x + 1)*arcsech(x)*diff(y(x), x)*exp(y(x)/arcsech(x) + exp(y(x)/arcsech(x))) - y(x)*exp(y(x)/arcsech(x) + exp(y(x)/arcsech(x))) + 2*x*sqrt((1 - x)/(x + 1))*(x + 1)*arcsech(x)^2 = 0;

-x*((1-x)/(x+1))^(1/2)*(x+1)*arcsech(x)*(diff(y(x), x))*exp(y(x)/arcsech(x)+exp(y(x)/arcsech(x)))-y(x)*exp(y(x)/arcsech(x)+exp(y(x)/arcsech(x)))+2*x*((1-x)/(x+1))^(1/2)*(x+1)*arcsech(x)^2 = 0

sol:=dsolve(ode);

expected_sol:=y(x)=arcsech(x)*ln(ln(2*x+_C1));

y(x) = arcsech(x)*ln(ln(2*x+_C1))

odetest(expected_sol,ode) assuming x>0

0

 

 

Download ode_solution_feb_6_2026.mw

I have the functions dx(t), dt(t), and dz(t).  They are all the same function.  I constructed the dz(t) function as a piecewise function, then copied it to dx(t) and dy(t).  The area under the function curves sum to one as I would expect.

How can I convert these functions into a PDF form so that I can perform mathematical operations on the PDFs, such as add the PDFs to create another PDF?

SphereFinal.mw

Noticed something strange.  When I type

restart;
F:=x-> (x^4+3*x^3-3*x^2-2*x-24)/(x^4-4*x^3-13*x^2+62*x-56);
u:=x->piecewise(x=-4,limit(F(x),x=-4),true,F(x));
u(-4);

Gives Error, (in F) numeric exception: division by zero which means it did not hit the first condition x=-4

But when I write this

restart;
F:=x-> (x^4+3*x^3-3*x^2-2*x-24)/(x^4-4*x^3-13*x^2+62*x-56);
A:=limit(F(x),x=-4);
u:=x->piecewise(x=-4,A,true,F(x));
u(-4)

Now it gives expected result 15/47

To avoid defining many variables, like A above, I'd like to just write the  limit inside.

Is there a way to make Maple accept the limit inside piecewise as written above? i.e. have it evaluate to 15/47?

Help says "The piecewise function evaluates its arguments on an as-needed basis."

Not sure what this means.

I tried adding eval, as in 

u:=x->piecewise(x=-4,eval(limit(F(x),x=-4)),true,F(x));

But this did nothing

Maple 2025.2

 

Should not the following two commands produce same solution?

f:=x->(x^2+3*x-4)*cos(x^2+3*x-5);
PDEtools:-Solve({f(x)=0,0<x,x<2},x);
solve({f(x)=0,0<x,x<2},x);

This is what the result looks like

Why Solve gives one solution and solve gives 2? Is this expected or a bug?

btw, the solution from solve is also not complete. There are 5 roots not 2.

Student:-Calculus1:-Roots(f(x),x=0..2);

 

I have two random variables:  x and y.  I want to multiply them and get the resulting Probability Density Function, z.  If you look below, Example 1 works as expected.  When I try Example 2, however, I get disappointing results.

Clearly, Example 2 involves nonzero lower boundaries, which is messing me up.  Does anyone have any suggestions for Example 2?

Example 1

with(Statistics)

x := RandomVariable(Uniform(0, 1))

_R

(1)

y := RandomVariable(Uniform(0, 2))

_R0

(2)

z = PDF(x*y, t)

z = piecewise(t < 0, 0, t <= 2, (1/2)*ln(2)-(1/2)*ln(t), 2 < t, 0)

(3)

 

 

Example 2

x := RandomVariable(Uniform(1, 2))

_R1

(4)

y := RandomVariable(Uniform(2, 3))

_R2

(5)

z := PDF(x*y, t)

int(piecewise(_t < 1, 0, _t < 2, 1, 2 <= _t, 0)*piecewise(t/_t < 2, 0, t/_t < 3, 1, 0)/abs(_t), _t = -infinity .. infinity)

(6)
 

NULL

Download MultiplyPDFFunctions.mw

Hello there,

There are two ways that I know of to define functions in maple:

f(x) :=      (1)

and 

f := x->     (2)

The issue that I'm noticing is that if I only use one method, everything works as I expect it to, but if I use both methods in the same document on a function with the same name eg. (doing f :=x->2x and then later in the document doing f(x) := 5x), (2) seems to completely overrule anything (1) says, even if (1) is used after. 
Can anyone explain why this is? 

I do not use table data struct in Maple and could not find anything in help on how to do this.

given a table T such as the following, typing indices(T) shows there are more than entry in each index

indices(T)

[[-0.687272727272727, -0.687272727272727, 1.],   [2.25818181818182, 2.25818181818182, 1.]], 

  [[-2.47, -1.47, 2.], [0.53, 1.53, 2.]], 

  [[0.245, -2.755, -2.], [2.745, -0.255, -2.]], 

  [[-2.6, -0.6, 3.], [0.379, 2.379, 3.]], 

  [[2.659, -1.341, -3.], [4.652, 0.652000000000001, -3.]], 

  [[-3.178, 0.822000000000001, 5.], [-1.185, 2.815, 5.]], 

  [[0.0672727272727271, -0.932727272727273, 0.], [3.06181818181818, 2.06181818181818, 0.]], 

  [[2.8895, -2.1105, -4.], [4.3895, -0.6105, -4.]], 

  [[1.01, -0.99, -1.], [4.02571428571429, 2.02571428571429, -1.]], 

  [[-3.63, -0.63, 4.], [-1.13875, 1.86125, 4.]]

In the above each entry in table has 2 indices. I want to keep only the first index in each entry so that it has only one, to become this

[[-0.687272727272727, -0.687272727272727, 1.]], 

[[-2.47, -1.47, 2.]], 

[[0.245, -2.755, -2.]],

 [[-2.6, -0.6, 3.]], 

[[2.659, -1.341, -3.]],

 [[-3.178, 0.822000000000001, 5.]],

 [[0.0672727272727271, -0.932727272727273, 0.]], 

[[2.8895, -2.1105, -4.]], 

[[1.01, -0.99, -1.]], 

[[-3.63, -0.63, 4.]]

And keep everything else as in in the Table. Just need to adjust the indices to be one entry instead of 2 or more.

Here is an example of such table


T:=table([([-.687272727272727, -.687272727272727, 1.], [2.25818181818182, 2.258181\
81818182, 1.])=COLOR(RGB,.63529412,.60392157,.60000000),([-2.47, -1.47, 2.], [.\
53, 1.53, 2.])=COLOR(RGB,.60784314,.47450980,.46274510),([.245, -2.755, -2.], [
2.745, -.255, -2.])=COLOR(RGB,.44705882,.52549020,.67058824),([-2.6, -.6, 3.],
[.379, 2.379, 3.])=COLOR(RGB,.57647059,.34509804,.32549020),([2.659, -1.341, -3\
.], [4.652, .652000000000001, -3.])=COLOR(RGB,.34901961,.46666667,.70980392),([
-3.178, .822000000000001, 5.], [-1.185, 2.815, 5.])=COLOR(RGB,.47058824,0.,.\
54901961e-1),([.672727272727271e-1, -.932727272727273, 0.], [3.06181818181818,
2.06181818181818, 0.])=COLOR(RGB,.62352941,.63529412,.65490196),([2.8895, -2.11\
05, -4.], [4.3895, -.6105, -4.])=COLOR(RGB,.22745098,.40392157,.78039216),([1.0\
1, -.99, -1.], [4.02571428571429, 2.02571428571429, -1.])=COLOR(RGB,.53725490,.\
57647059,.65490196),([-3.63, -.63, 4.], [-1.13875, 1.86125, 4.])=COLOR(RGB,.537\
25490,.20392157,.18823529)])

Is it possible to do this in code?

Maple 2025.2

Hello all,

This will be my LAST (I swear) question about translating a little function from Mathematica to Maple.

rand := RandomReal[{-5, 5}, 20]

ListPlot[rand]

 

ListListLinePlot[rand]

In[16]:= line = Fit[rand, {1, x}, x]

Out[16]= 0.247498 - 0.0131912 x

In[17]:= parabol = Fit[rand, {1, x, x^2}, x]

Out[17]= -1.82858 + 0.31249 x - 0.0082569 x^2

In[18]:= cos = Fit[rand, {1, x, Cos[x]}, x]

Out[18]= 0.483172 - 0.0302095 x - 0.271457 Cos[x]

Plot[{ListLinePlot[rand], line, parabol, cos}, {x, 0, 20}]

#graph omitted by request of users here.

So, then, my LAST question will be :

How to translate this to Maple ?

Thank you very much.

JM

Hello again,

I think I have not been clear enough in my question.

I reformulate :

Is it possible in Maple to create matrices whose elements are also matrices

and this to any level ?

For the Dimensions of a matrix it's ok for me.

thank you 

JM

Hello all,

I just need a hint how to enter "matrices" in Maple which are lists of lists and so on.

Since I gave up on "math"ematica I would like to be able to enter what is just

below (with the dimension).

Is it doable in Maple...I guess yes :)

M = {{a, {1, a, -0.5}}
, {{b, {1}}}, c + d}
Out[5]= {a, {1, a, -0.5}, {{b, {1}}}, c + d}
In[8]:= MatrixForm[M]
Out[8]//MatrixForm=
a
{1, a, -0.5}
{{b, {1}}}
c + d
In[9]:= Dimensions[M]
Out[9]= {4}

PS: Is a moderator ready to make me with a reputation of 100 in order I can enter tags.

Thank you for everything.

Regards,

JM

I am not able to find place in help which lists which changes interface(typesetting = extended); makes compared to interface(typesetting = standard);

Reason  I am asking, is that in interface(typesetting = extended); Maple adds a small annoying "dot"  between each term for multiplication, which is not there in standard.

Is there a place in documentation that mentions this as part of extended? Where to find it?

in Matlab and Mathematica it is possible to put the labels in contour plot, directly on the lines (with nice positioning).

This makes it much much easier to see the level of each contour line since the values are on the lines,  without having to jump to the legend and guess the color and try to visually match colors with the plot.

For example, in Matlab

clear; close all;
x = 0:0.05:20;
y = 0:0.05:15;
[x,y] = meshgrid(x,y);
z = (11-x-y).^2 + (1+x+10*y-x.*y).^2;
[C,h] =contour(x,y,z,10);
clabel(C,h)

gives

In Maple

f:=(11 - x - y)^2 + (1 + x + 10*y - x*y)^2:
plots:-contourplot(f, x=0..20, y=0..15,
         legend=true,
         contours=10,
         'axes'='boxed',
         legendstyle=[location=right], 
         colorscheme="DivergeRainbow");

Is there a way to tell Maple to put contour labels on the "middle" of the level lines (contour lines) similar to what Matlab does?

I see no such option in https://www.maplesoft.com/support/help/maple/view.aspx?path=plots/contourplot

1 2 3 4 5 6 7 Last Page 1 of 17